import { View } from "../../../mvc/core/View";
import { LayerManager } from "../../manager/LayerManager";
import { ObjCreate } from "../common/ObjCreate";
import { ResFileConst } from "../../resource/ResFileConst";
import { Cache } from "../../cache/Cache";
import { Language } from "../../../../extend/language/Language";
import { Alert } from "../../../../com/mui/controls/Alert";
import { EArenaProcess } from "../../../../Message/Public/EArenaProcess";
import { ENpcEffect } from "../../../../Message/Public/ENpcEffect";
import { AIManager } from "../../scene/ai/AIManager";
import { AIType } from "../../scene/ai/AIType";
import { ObjectPool } from "../../../../com/gengine/utils/pools/ObjectPool";
import { GLoadedButton } from "../../../../com/mui/controls/GLoadedButton";
type int = number;
//class ArenaCrossIconView
    
    export  class ArenaCrossIconView extends View
    {
        constructor()
        {
            super();
            this.layer = LayerManager.rightTopUILayer;
            this.init();
            return;
        }

        /* internal  */init(): void
        {
            this._btnArenaCross = ObjCreate.createGLoadedButton(ResFileConst.ArenaCrossEnterRoomIcon, 0, 0, 60, 50, this);
            this._btnArenaCross.addEventListener(flash.events.MouseEvent.CLICK, this.onArenaCrossClick);
            this.showLightMask();
            return;
        }

        /* internal  */onArenaCrossClick(arg1: Object /* flash.events.MouseEvent */): void
        {
            this.hideLightMask();
            var loc1=Cache.instance.arenaCross.isOpen;
            var loc2=Language.getString(44211);
            if (loc1) 
            {
                loc2 = Language.getString(44212);
            }
            Alert.showCloseBtn = true;
            Alert.yesLabel = Language.getString(44213);
            Alert.okLabel = Language.getString(44214);
            Alert.buttonWidth = 70;
            var loc3=Language.getStringByParam(44215, loc2);
            if (Cache.instance.arenaCross.arenaCrossInfo && (Cache.instance.arenaCross.arenaCrossInfo.process == EArenaProcess._EArenaElimination4 && Cache.instance.arenaCross.arenaCrossInfo.isOpen == false || Cache.instance.arenaCross.arenaCrossInfo.process == EArenaProcess._EArenaGroupMatch1 && Cache.instance.arenaCross.arenaCrossInfo.isOpen)) 
            {
                loc3 = Language.getString(44271);
            }
            if (Cache.instance.arenaCross.arenaCrossInfo && (Cache.instance.arenaCross.arenaCrossInfo.process == EArenaProcess._EArenaGroupMatch1 && Cache.instance.arenaCross.arenaCrossInfo.isOpen == false || Cache.instance.arenaCross.arenaCrossInfo.process == EArenaProcess._EArenaFinalMatch1 || Cache.instance.arenaCross.arenaCrossInfo.process == EArenaProcess._EArenaFinalMatch2 && Cache.instance.arenaCross.arenaCrossInfo.isOpen)) 
            {
                loc3 = Language.getString(44365);
            }
            Alert.show(loc3, null, Alert.YES | Alert.OK, null, this.onClickClose);
            return;
        }

        /* internal  */onClickClose(arg1: int): void
        {
            var loc1=Cache.instance.scene.getNpcByEffect(ENpcEffect._ENpcEffectArenaCross);
            if (arg1 != Alert.YES) 
            {
                if (arg1 == Alert.OK) 
                {
                    AIManager.onAIControl(loc1, AIType.AI_Convey);
                }
            }
            else 
            {
                AIManager.onAutoPathAIControl(loc1);
            }
            return;
        }

        public showLightMask(): void
        {
            if (!this._lightMask) 
            {
                this._lightMask = ObjectPool.getObject(LightMask);
                this._lightMask.transform.matrix = new Object /* flash.geom.Matrix */();
                this._lightMask.x = 0;
                this._lightMask.y = 0;
                this._lightMask.scaleX = 70 / 42.5;
                this._lightMask.scaleY = 59 / 42.5;
                this.addChild(this._lightMask);
            }
            return;
        }

        public hideLightMask(): void
        {
            if (this._lightMask) 
            {
                if (this._lightMask.parent) 
                {
                    this._lightMask.parent.removeChild(this._lightMask);
                }
                this._lightMask.x = 0;
                this._lightMask.y = 0;
                this._lightMask.width = 40;
                this._lightMask.height = 40;
                ObjectPool.disposeObject(this._lightMask);
                this._lightMask = null;
            }
            return;
        }

        /* internal */ /* var */_btnArenaCross: GLoadedButton;

        /* internal */ /* var */_lightMask: LightMask;
    }
